#include <stdio.h>

int Turn(char turn[100], char picture[100][100], char T[100][100], char ch, int n, int x,int y)
{
	int i = 0;
	int j = 0;
	int tmp = 0;
	for (i=0; turn[i] != '\n'; i++)
	{
		if (turn[i] == 'L')
		{
			switch (ch)
			{
			case '^':
				ch = '>';
				break;
			case '>':
				ch = 'v';
				break;
			case '<':
				ch = '^';
				break;
			case 'v':
				ch = '<';
				break;
			default:
				break;
			}
			tmp = y;
			y = n - 1 - x;
			x = tmp;
		}
		else if (turn[i] == 'R')
		{
			switch (ch)
			{
			case '^':
				ch = '<';
				break;
			case '>':
				ch = '^';
				break;
			case '<':
				ch = 'v';
				break;
			case 'v':
				ch = '>';
				break;
			default:
				break;
			}
			tmp = x;
			x = n - 1 - y;
			y = tmp;
		}
		else
			return 0;
	}
	T[x][y] = ch;
	return 0;
}

int main()
{
	int n = 0;
	char turn[100] = { '\0' };
	int i = -1;
	int j = 0;
	char ch = 0;

	scanf("%d", &n);
	while (getchar() != '\n')
	{
		;
	}
	do
	{
		i++;
		scanf("%c", &turn[i]);
	} while (turn[i] != '\n');

	char picture[100][100] = { 0 };
	char T[100][100] = { 0 };
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			scanf("%c", &picture[i][j]);
			Turn(turn, picture, T, picture[i][j], n, i, j);
		}
		while (getchar() != '\n')
		{
			;
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			printf("%c", T[i][j]);
		}
		printf("\n");
	}

	return 0;
}